<%--
  Created by IntelliJ IDEA.
  User: 全谢民
  Date: 2023/10/1
  Time: 8:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="path" value="${pageContext.request.contextPath }"/>
<html>
<head>
    <title>我的评论</title>
    <%--左侧样式--%>
    <link rel="stylesheet" type="text/css" href="${path}/css/user_page_css/user.css">
    <%--头部底部样式--%>
    <link rel="stylesheet" type="text/css" href="${path}/css/user_page_css/home_page.css">
    <%--右侧样式--%>
    <link rel="stylesheet" type="text/css" href="${path}/css/user_page_css/userComments.css">
    <%--右侧底部样式--%>
    <link rel="stylesheet" type="text/css" href="${path}/css/user_page_css/search.css">
    <%--导入js--%>
    <script rel="script" type="text/javascript" src="${path}/js/jquery-3.6.4.js"></script>
    <style>
        .main{
            height: 125%;
        }
    </style>
</head>
<body>
<%--前端用户--%>
<%@include file="header.jsp" %>
<div class="content">
    <div class="main">
        <div class="user-profile-nav">
            <h1>个人中心</h1>
            <a class="userBack" onclick="jquery:window.location='userOrderDetail.jsp'">我的订单</a>
            <a class="userBack" onclick="jquery:window.location='userCollection.jsp'">我的收藏</a>
            <a class="userBack" style="background-color: #ef4238" onclick="jquery:window.location='userComments.jsp'">我的评论</a>

            <a class="userBack" onclick="jquery:window.location='userShoppingAddress.jsp'">收货地址</a>
            <a class="userBack" onclick="jquery:window.location='userProfile.jsp'">基本信息</a>
            <a class="userBack" onclick="jquery:window.location='userSetUp.jsp'">账号设置</a>
            <%--登陆方式 /1.手机号验证2.密码 3.邮箱 4.实名认证--%>
            <a class="userBack" onclick="jquery:window.location='userTicketPeople.jsp'">常用购票人</a>
            <%--姓名/证件类型/身份证号--%>
            <a class="userBack" onclick="jQuery:window.location=''">退出登录</a>
        </div>
        <div class="comment-container">
            <div class="profile-title">
                我的评论
            </div>
            <div class="comment_box">
                <c:set var="page" value="${requestScope.page}"/>
                <c:choose>
                    <c:when test="${empty page}">
                        <h2>暂无收藏</h2>
                    </c:when>
                    <c:otherwise>
                        <c:forEach var="cl" items="${page.dataList}">
                            <div id="${cl.commentId}">
                                <div class="comment_header">
                                    <span class="user_image"><img
                                            src="${path}/images/userAvatar/${cl.userPicture}"></span>
                                    <span class="userName">${cl.userName}</span>
                                    <span class="comment_date">${cl.commentTime}</span>
                                        <%--                            <span class="wGood_img"></span>--%>
                                    <span class="rGood_img"></span>
                                    <span class="goodCount">${cl.commentGood}</span>
                                    <span class="del_comment" onclick="del_comment(${cl.commentId})"></span>
                                </div>
                                <div class="comment_body">
                                    <div class="poster">
                                        <img src="${path}/images/user_page_images/typeImages/homePageImages/${cl.activityPicture}">
                                    </div>
                                    <div class="comment_content">
                                        <div class="movie-name">${cl.activityType}：${cl.activityName}</div>
                                        <div class="">${cl.commentContent}</div>
                                    </div>
                                </div>
                            </div>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>
                <%--                底部的页码--%>
                <div class="pagination">
                    <div class="el-pagination is-background">
                        <button type="button" disabled="disabled" class="btn-prev">
                            <i class="el-icon el-icon-arrow-left"></i>
                        </button>
                        <ul class="el-pager">
                            <c:forEach var="i" begin="1" end="${page.totalPageCount}">
                                <li
                                        <c:if test="${page.currPageNo==i}">class="number active"</c:if>
                                        <c:if test="${page.currPageNo!=i}">class="number"</c:if>
                                        onclick="jquery:window.location='${path}/servlet/userComment/userCommentAll?userId=1&index=${i}'">${i}</li>
                            </c:forEach>
                        </ul>
                        <button type="button" class="btn-next">
                            <i class="el-icon el-icon-arrow-right"></i>
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%@include file="footer.jsp" %>
<script>
    function del_comment(commentId) {
        var str = confirm("您确定要删除该评论嘛？删除后，不可恢复～");
        if (str) {
            $.post("${path}servlet/userComment/userDelComment?commentId="+commentId, function (result) {
                if (result > 0) {
                    alert("删除成功！");
                    $("#" + commentId).remove();
                } else {
                    alert(result);
                    alert("删除失败")
                }
            }, "text");
        }
    }
</script>
</body>
</html>
